package lambda.reduce;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class Test2 {
	public static void main(String[] args) {
		List<View> list =new ArrayList<>();
		list.add(new View("张三", "1", "2"));
		list.add(new View("张三", "3", "4"));
		list.add(new View("李四", "5", "6"));
		
		
		Map<String, List<String>> aa=list.stream().collect(Collectors.groupingBy(x->x.getName(), LinkedHashMap::new, Collectors.reducing(new ArrayList<String>(),(emp)->{
			List<String> ll=new ArrayList<>();
			ll.add(emp.getTel());
			ll.add(emp.getParenttel()+"");
			return ll;
		},(x,y)->{
			
			System.out.println(x);
			System.out.println(y);
			System.out.println("============");
			
			List<String> ll=new ArrayList<>();
			ll.addAll(x);
			ll.addAll(y);
			return ll;
		})));
		
		
		System.out.println(aa);
	}
}


class View{
	private String name="";
	private String tel="";
	private String parenttel="";
	public View(String name, String tel, String parenttel) {
		super();
		this.name = name;
		this.tel = tel;
		this.parenttel = parenttel;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getTel() {
		return tel;
	}
	public void setTel(String tel) {
		this.tel = tel;
	}
	public String getParenttel() {
		return parenttel;
	}
	public void setParenttel(String parenttel) {
		this.parenttel = parenttel;
	}
	
	
}